import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_jd/pages/tabbar/cart/controller.dart';
import 'package:flutter_jd/ui/pages/cart/checkbox.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// 底部结算区域
class CartBottomWrap extends GetWidget<CartController> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 50.h,
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border(
          top: BorderSide(
            color: Color(0xFFF9F9F9),
          ),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            children: [
              _buildSelectAll(),
              Container(
                margin: EdgeInsets.only(left: 8.w),
                child: Text('全选', style: TextStyle(fontSize: 12.sp)),
              ),
              Container(
                margin: EdgeInsets.only(left: 5.w),
                child: Text(
                  '合计:',
                  style: TextStyle(
                    fontSize: 15.sp,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ),
              Obx(
                () => Container(
                  margin: EdgeInsets.only(left: 5),
                  child: Text(
                    // '¥${controller.totalPrice.toStringAsFixed(2)}',
                    '¥${controller.totalPrice}',
                    style: TextStyle(
                      fontSize: 15.sp,
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                ),
              ),
            ],
          ),
          Row(
            children: [
              Container(
                height: 35.h,
                margin: EdgeInsets.only(right: 15.w),
                padding: EdgeInsets.only(left: 13.w, right: 5.w),
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                    begin: Alignment.topLeft,
                    end: Alignment.bottomRight,
                    colors: [
                      Color(0xFFFA2F19),
                      Color(0xFFFA722E),
                    ],
                  ),
                  borderRadius: BorderRadius.circular(20.r),
                ),
                alignment: Alignment.center,
                child: Text(
                  '去结算(${controller.selectedNumber.toString()}）',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 14.sp,
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }

  _buildSelectAll() {
    return Container(
      margin: EdgeInsets.only(left: 16.w),
      child: GestureDetector(
        onTap: () {
          controller.selectAllClick();
        },
        child: CartCheckbox(controller.isSelectAll.value),
      ),
    );
  }
}
